<template>
	<view>
		<text>当前传入id是{{id}}</text>
		<text v-if="response">接口返回: {{responseString}}</text>
	</view>
</template>

<script>
	import {get} from '@/api/base.js'
	import apiHelper from '@/mixins/apiHelper.js'
	export default {
		name:"commonComponent",
		mixins: [
			apiHelper
		],
		props: {
			id: {
				type: String,
				default(){
					return ''
				}
			}
		},
		data() {
			return {
				response: null
			};
		},
		computed: {
			responseString(){
				return JSON.stringify(this.response)
			}
		},
		methods: {
			getContent(){
				this.$sendOrToast(get, 'api/xxx', {id}).then((resp)=>{
					this.response = resp
					
					/*
					 * 优先考虑事件形式
					*/
					this.$emit('response', resp)
				}).catch((err)=>{})
			},
			
			/**
			 * 向外部暴露接口
			 */
			getResponse(){
				return this.response
			}
		},
		onShow(){
			
		}
	}
</script>

<style>

</style>